
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:Initialize()

	self.Entity:SetName("Shockwave")
	self.Entity:SetModel( "models/items/combine_rifle_ammo01.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )

	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
		phys:EnableGravity(false)
		phys:EnableDrag(false)
		phys:EnableCollisions(false)
	end

	self.PhysObj = self.Entity:GetPhysicsObject()

	self.Entity:SetColor(0,255,0,0)

	self.Gas = ents.Create("env_smoketrail")
	self.Gas:SetAngles( self.Entity:GetAngles()  )
	self.Gas:SetPos( self.Entity:GetPos() )
	self.Gas:SetParent( self.Entity )
	self.Gas:SetKeyValue("startcolor", "180 140 80")
	self.Gas:SetKeyValue("endcolor", "200 170 129")
	self.Gas:SetKeyValue("startsize","50")
	self.Gas:SetKeyValue("endsize","50")
	self.Gas:SetKeyValue("lifetime", "1")
	self.Gas:SetKeyValue("opacity", ".5")
	self.Gas:SetKeyValue("spawnrate","20")
	self.Gas:Spawn()
	self.Gas:Activate()
	
	self.STime = CurTime()
	self.CTime = 0

end

function ENT:PhysicsUpdate()

end

function ENT:SpawnFunction( ply, tr )

	if ( !tr.Hit ) then return end

	local SpawnPos = tr.HitPos + tr.HitNormal * 36

	local ent = ents.Create( "swavedust" )
	ent:SetPos( SpawnPos )
	ent:Spawn()
	ent:Activate()
	return ent
end

function ENT:Think()

	self.Entity:SetColor(0,255,0,0)

	self.CTime = CurTime() - self.STime

	self.Gas:SetKeyValue("startsize", 40 - (self.CTime * 10) )
	self.Gas:SetKeyValue("endsize", 50 - (self.CTime * 10) )

	--self.Entity:Remove()
end

function ENT:PhysicsCollide( data, physobj )
	
end

function ENT:OnTakeDamage( dmginfo )
	
end

function ENT:Use( activator, caller )

end